package cn.buk.tms.eotms.report.dto;

import cn.buk.common.flight.dto.FlightBasicInfo;
import cn.buk.tms.common.dto.flight.BaseChangeOrderFlightDto;
import cn.buk.tms.eotms.entity.FlightInfo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 用于报表的退票
 * @author william
 *
 */
public class ReportFlightRefundDto extends ReportBaseDto {

	private final double serviceCharge;
	private final double ticketAmount;
	private final double airRefundCharge;

	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private final Date psgRefundDate;

	private final int reasonCode;

	public ReportFlightRefundDto(String balanceCode, String ticketNo, Date opDate, String passengerName, String routeDetail,
															 double ticketAmount, double airRefundCharge, double serviceCharge,
															 double passengerRefundAmount, Date psgRefundDate,
															 Integer reasonCode,
															 String op1, int billId, String bePaid0) {
//		this.passengerRefundAmount = -passengerRefundAmount; // 实退客户(数据库保存的是正数）
		super(op1, opDate, billId, -passengerRefundAmount,
						bePaid0 == null ? 0 : Integer.parseInt(bePaid0));

		this.balanceCode = balanceCode;
		this.ticketNo = ticketNo;
		this.name = passengerName;
		this.routeDetail = routeDetail;

		this.ticketAmount = ticketAmount; // 机票客户的原付金额
		this.airRefundCharge = airRefundCharge; // 航司退票费
		this.serviceCharge = serviceCharge; // 服务费

		this.psgRefundDate = psgRefundDate; // 实退客户日期

		this.reasonCode = reasonCode == null ? 0 : reasonCode;
	}

	public String getReasonCodeDesc() {
//        * 0-自愿退票
//                * 1-非自愿退票
//                * 4-废票
		int reasonCode = this.getReasonCode();
		switch (reasonCode) {
			case 0:
				return "自愿退票";
			case 1:
				return "非自愿退票";
			case 4:
				return "废票";
			default:
				return "?";
		}
	}

	private String balanceCode;

	private String ticketNo;

	/**
	 * 乘机人姓名
	 */
	private String name;
	@JsonIgnore
	private String routeDetail;

	private List<FlightBasicInfo> flights;

	/**
	 * 是否已审核
	 */
	private String audited;

	public String getTicketNo() {
		return ticketNo;
	}

	public void setTicketNo(String ticketNo) {
		this.ticketNo = ticketNo;
	}


	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public double getServiceCharge() {
		return serviceCharge;
	}

	public String getBalanceCode() {
		return balanceCode;
	}

	public String getRouteDetail() {
		if (routeDetail == null) {
			return "";
		} else {
			return routeDetail;
		}
	}

	public void setRouteDetail(String routeDetail) {
		this.routeDetail = routeDetail;
	}


	public List<FlightBasicInfo> getFlights() {
		if (flights == null) {
			flights = new ArrayList<>();
		}
		return flights;
	}


	public double getTicketAmount() {
		return ticketAmount;
	}

	public double getAirRefundCharge() {
		return airRefundCharge;
	}

	public Date getPsgRefundDate() {
		return psgRefundDate;
	}

	public int getReasonCode() {
		return reasonCode;
	}
}
